<template>
  <view>
    <web-view
      :webview-styles="webviewStyles"
      :src="`https://api.77du.net/ciff/miniappapi/news/${id}.html?id=${id}&token=${token}`"
    ></web-view>
  </view>
</template>

<script>
import { photoArticle } from "../../api/api";
export default {
  data() {
    return {
      webviewStyles: {
        progress: {
          color: "#ff0000",
        },
      },
      id: "",
      token: "",
      share: {},
    };
  },
  async onLoad({ id }) {
    let token = uni.getStorageSync("userInfo").token || "";
    this.token = token;
    this.id = id;
    const res = await photoArticle(this.id);
    if (res[1].data.code == "000000") {
      const data = res[1].data.data;
      const { shareImage, shareSummary, shareTitle } = data;
      this.share = {
        shareImage,
        shareSummary,
        shareTitle,
      };
    }
    console.log(
      `https://api.77du.net/ciff/miniappapi/news/${id}.html?id=${id}&token=${token}`
    );
  },
  onShareAppMessage(res) {
    return {
      title: this.share.shareTitle,
      path: "/pages/article/article?id=" + this.id,
      imageUrl: this.share.shareImage,
    };
  },
};
</script>

<style lang="scss" scoped></style>
